

{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'css/baseTable.css' %}"/>

<h1>{{ functionname }} |</h1>


<div class="table_unit">
    <div class="search_block">
        <form class="form-search" onsubmit="return false;">
            <input id="search_input" class="search_input" type="text" placeholder="搜 索" value="{{ searchMsg }}">
            <button class="search_btn" type="submit" onclick="onSearchBtn({{ searchURL }})">查找</button>
        </form>
    </div>

    <table id="tbl">
        <thead>
        <tr>
            {% for field in fieldlist %}
                <th>{{ field }}</th>
            {% endfor %}
        </tr>
        </thead>
        <tbody>

        {% for result in resultlist %}
            <tr>
                {#权限管理#}
                {% if function == 'right' %}
                    <td>{{ result.username.username }}</td>
                    <td>{{ result.rolename.rolename }}</td>
                    <td><a onclick="onAuthorizationClick('{{ result.username.username }}')">编辑</a></td>
                {% endif %}

                {#新用户权限分配#}
                {% if function == 'newuser_authorize' %}
                    <td>{{ result.username.username }}</td>
                    <td>{{ result.rolename.rolename }}</td>
                    <td><a onclick="onAuthorizationClick('{{ result.username.username }}')">授权</a></td>
                {% endif %}

                {#待定稿合同#}
                {% if function == 'pending_contract' %}
                    <td>{{ result.conid.conid }}</td>
                    <td>{{ result.conid.conname }}</td>
                    <td>{{ result.conid.username.username}}</td>
                    <td>{{ result.modifytime }}</td>
                    <td><a onclick="onFinalizeClick('{{ result.conid.conid }}')">定稿</a></td>
                {% endif %}

                {#已定稿合同管理#}
                {% if function == 'finalized_contract' %}
                    <td>{{ result.conid.conid }}</td>
                    <td>{{ result.conid.conname }}</td>
                    <td>{{ result.conid.username.username}}</td>
                    <td>{{ result.modifytime }}</td>
                {% endif %}

                {#流程查询#}
                {% if function == 'process_query' %}
                    <td>{{ result.conid.conid }}</td>
                    <td>{{ result.conid.conname }}</td>
                    <td>{{ result.conid.username.username}}</td>
                    <td>{{ result.modifytime }}</td>
                    {% if result.type == 1 %}
                        <td>起草完成</td>
                    {% elif result.type == 2 %}
                        <td>会签完成</td>
                    {% elif result.type == 3 %}
                        <td>定稿完成</td>
                    {% elif result.type == 4 %}
                        <td>审批完成</td>
                    {% elif result.type == 5 %}
                        <td>签订完成</td>
                    {% elif result.type == 6 %}
                        <td>已作废</td>
                    {% endif %}
                    <td><a onclick="onContractDetail('{{ result.conid.conid }}')">详情</a></td>
                {% endif %}

                {#待会签合同#}
                {% if function == 'countersigning_contract' %}
                    <td>{{ result.conid.conid }}</td>
                    <td>{{ result.conid.conname }}</td>
                    <td>{{ result.username.username}}</td>
                    <td>{{ result.modifytime }}</td>
                    <td><a onclick="onCountersignClick('{{ result.conid.conid }}','{{ result.username.username}}')">会签</a></td>
                {% endif %}

                {#已会签合同#}
                {% if function == 'countersigned_contract' %}
                    <td>{{ result.conid.conid }}</td>
                    <td>{{ result.conid.conname }}</td>
                    <td>{{ result.username.username}}</td>
                    <td>{{ result.modifytime }}</td>
                {% endif %}

                {#待审批合同#}
                {% if function == 'contract_approving' %}
                    <td>{{ result.conid.conid }}</td>
                    <td>{{ result.conid.conname }}</td>
                    <td>{{ result.username.username}}</td>
                    <td>{{ result.modifytime }}</td>
                    <td><a onclick="onApprovalClick('{{ result.conid.conid }}','{{ result.username.username}}')">审批</a></td>
                {% endif %}

                {#已审批合同#}
                {% if function == 'contract_approved' %}
                    <td>{{ result.conid.conid }}</td>
                    <td>{{ result.conid.conname }}</td>
                    <td>{{ result.username.username}}</td>
                    <td>{{ result.modifytime }}</td>
                {% endif %}

                {#待签订合同#}
                {% if function == 'contract_signing' %}
                    <td>{{ result.conid.conid }}</td>
                    <td>{{ result.conid.conname }}</td>
                    <td>{{ result.username.username}}</td>
                    <td>{{ result.modifytime }}</td>
                    <td><a onclick="onSignClick('{{ result.conid.conid }}','{{ result.username.username}}')">签订</a></td>
                {% endif %}

                {#已签订合同#}
                {% if function == 'contract_signed' %}
                    <td>{{ result.conid.conid }}</td>
                    <td>{{ result.conid.conname }}</td>
                    <td>{{ result.username.username}}</td>
                    <td>{{ result.modifytime }}</td>
                {% endif %}

                {#待分配合同#}
                {% if function == 'contract_distributing' %}
                    <td>{{ result.conid.conid }}</td>
                    <td>{{ result.conid.conname }}</td>
                    <td>{{ result.conid.username.username }}</td>
                    <td>{{ result.modifytime }}</td>
                    <td><a onclick="onDistribute('{{ result.conid.conid }}')">分配</a></td>
                {% endif %}

                {#已分配合同#}
                {% if function == 'contract_distributed' %}
                    <td>{{ result.conid.conid }}</td>
                    <td>{{ result.conid.conname }}</td>
                    <td>{{ result.conid.username.username }}</td>
                    <td>{{ result.modifytime }}</td>
                    <td><a onclick="onContractDistributeDetail('{{ result.conid.conid }}')">详情</a></td>
                {% endif %}

                {#客户信息表#}
                {% if function == 'customer_info' %}
                    <td>{{ result.cusid }}</td>
                    <td>{{ result.cusname }}</td>
                    <td>{{ result.tel }}</td>
                    <td><a onclick="onCostomerDetail('{{ result.cusid }}')">详情</a></td>
                {% endif %}

                {#日志信息表#}
                {% if function == 'view_log' %}
                    <td>{{ result.username }}</td>
                    <td>{{ result.operateobject }}</td>
                    <td>{{ result.content }}</td>
                    <td>{{ result.operatetime }}</td>
                {% endif %}
            </tr>
        {% endfor %}

        </tbody>
    </table>

    <div class="pagination">
        <div class="current_page">
            <a>当前页：{{ current_page }}</a>
        </div>

        <ul>
            <li><a onclick="onPrePageClick()">上一页</a></li>
            {% for page in pageslist %}
                <li><a onclick="onPageClick(this)">{{ page }}</a></li>
            {% endfor %}
            <li><a onclick="onNextPageClick()">下一页</a></li>
        </ul>
    </div>

</div>